package com.lagou.controller;

import com.lagou.common.ResponseCode;
import com.lagou.common.ServerResponse;
import com.lagou.service.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/account")
public class AccountController {
    @Autowired
    private IAccountService accountService;

    @RequestMapping("/transfer.do")
    @ResponseBody
    public ServerResponse<String > transfer(String inName, String outName, double money){
        Integer code = accountService.transfer(inName, outName, money);

        if(ResponseCode.SUCCESS.getCode() == code){
            System.out.println("转账成功");
            return ServerResponse.createBySuccessMsg("转账成功");
        } else {
            return ServerResponse.createByErrorMsg("转账失败");
        }


    }
}
